package com.wlr.study.leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * @author HustleLr
 * @version 1.0.0
 * @date 2023/10/25 19:47
 * @describe LeetCode141
 */
public class LeetCode141 {
    public boolean hasCycle(ListNode head) {
        Map<ListNode, Integer> map = new HashMap<>();
        int i = 0;
        if (null != head) {
            while (head.next != null) {
                if (map.containsKey(head)) {
                    return true;
                }
                map.put(head, i++);
                head = head.next;
            }
        }
        return false;
    }

    public static void main(String[] args) {

    }
}
